#include <stdlib.h>
#include "NewLife.h"
#include "bootutil.h"
#include "knlvar.h"

extern "C" char * sbrk(int incr)
{
	static char *heap_end = NULL;	// Current end of heap
	static char *heap_top = NULL;	// Top of allocated memory
	char *prev_heap_end;	// Prev end of heap

	if(heap_end==NULL)
	{
		heap_end = (char *)KERNEL_RESERVED_START;
		heap_top = (char *)KERNEL_RESERVED_END;
	}
	prev_heap_end = heap_end;

	if(heap_end+incr > heap_top) 
	{
		kprintf("Currently not implement sbrks");
		return NULL;
	} 
	
	heap_end += incr;
	return prev_heap_end;
}

